package com.example.cdtutils;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Kent HAN
 * @date 2021/8/27
 */
public class QrCodeEx {
    /*
     *   小柴加电
     *   https://www.bjecpower.com/xcwx/index.html#/jumpCode?type=22_c45b0cc324b0400abac742fb3e0a1d4e_8efbf9df94414b7b8b13dc88e72056ba_00090181801B
     *   22 类型
     *   c45b0cc324b0400abac742fb3e0a1d4e 公司
     *   8efbf9df94414b7b8b13dc88e72056ba 站ID
     *   00090181801B 枪号
     */
    static String qrCode = "https://www.bjecpower.com/xcwx/index.html#/jumpCode?type=22_c45b0cc324b0400abac742fb3e0a1d4e_8efbf9df94414b7b8b13dc88e72056ba_00090181801B";
    static List<String> result = RegexUtils.getMatchGroups(qrCode,"type=([0-9a-zA-z]+?)_([0-9a-zA-z]+?)_([0-9a-zA-z]+?)_([0-9a-zA-z]+)",4);

    /*
     * 广州电盟
     * http://wx.gzdianmeng.com/app/download?orgNo=MA9Y0HG29&code=32010600072004-01
     */
    static String qrCode2 = "http://wx.gzdianmeng.com/app/download?orgNo=MA9Y0HG29&code=32010600072004-01";
    static String qrcodeRule = "http://wx.gzdianmeng.com/app/download";
    static Matcher matcherDM = Pattern.compile("^" + qrcodeRule + "\\?orgNo=([0-9a-zA-Z]{9}+)&code=([0-9a-zA-Z_|-]+)$").matcher(qrCode2);



    public static void main(String[] args) {
        System.out.println(result.get(0));
        System.out.println(result.get(1));
        System.out.println(result.get(2));
        System.out.println(result.get(3));
        System.out.println(result.get(4));

        if (matcherDM.find()) {
            matcherDM.reset();
            while (matcherDM.find()) {
                System.out.println(matcherDM.group(2));
            }
        }
    }
}
